package com.project.pudongdata.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;

import com.project.util.DateUtils;
import com.project.pudongdata.dto.SearchDto;
import com.project.pudongdata.entity.*;
import com.project.pudongdata.mapper.*;
import com.project.pudongdata.service.PdDisasterRecoveryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
@Slf4j
@Service
public class PdDisasterRecoveryServiceImpl  implements PdDisasterRecoveryService {
    @Resource
    private TXianluMapper xianluMapper;

    @Resource
    private TXlBcMapper xlBcMapper;

    @Resource
    private TQyBcMapper qyBcMapper;

    @Resource
    private TXlShoumobanfczdMapper xlShoumobanfczdMapper;

    @Resource
    private TQyShoumobanfczdMapper qyShoumobanfczdMapper;

    @Resource
    private TXlQiqizhanfczdMapper xlQiqizhanfczdMapper;

    @Resource
    private TQyQiqizhanfczdMapper qyQiqizhanfczdMapper;

    @Resource
    private TXlGuapaifczdMapper xlGuapaifczdMapper;

    @Resource
    private TQyGuapaifczdMapper qyGuapaifczdMapper;

    @Resource
    private TXlZxMapper xlZxMapper;

    @Resource
    private TQyZxMapper qyZxMapper;

    @Resource
    private TXlClzxMapper xlClzxMapper;

    @Resource
    private TQyClzxMapper qyClzxMapper;

    @Resource
    private TXlClccMapper xlClccMapper;

    @Resource
    private TQyClccMapper qyClccMapper;

    @Resource
    private TXlGfbcpcMapper xlGfbcpcMapper;

    @Resource
    private TXlPingjunCSMapper xlPingjunCSMapper;


    @Override
    public List<TXianlu> selectTXianluList(SearchDto searchDto) throws Exception {
        log.info("selectTXianluList invoke...");

        LocalDate localDate = DateUtils.StrToLocalDate(searchDto.getSearchDate(),DateUtils.FORMAT_SIMPLE);
        Integer rq = Integer.parseInt(localDate.format( DateTimeFormatter.ofPattern("yyyyMMdd")));

//        List<TXianlu> list = baseMapper.selectTXianluList(searchDto);
       List<TXianlu> list = xianluMapper.selectList(Wrappers.<TXianlu>lambdaQuery().eq(TXianlu::getRq,rq));
//        List<TXianlu> list = xianluMapper.selectList(new LambdaQueryWrapper<TXianlu>().eq(TXianlu::getRq,rq));
        return list;
    }

    /**
     * 2、线路班次数据
     * @param searchDto
     * @return
     * @throws Exception
     */
    public List<TXlBc> selectTXlBcList(SearchDto searchDto) throws Exception{
        log.info("selectTXlBcList invoke...");

        LocalDate localDate = DateUtils.StrToLocalDate(searchDto.getSearchDate(),DateUtils.FORMAT_SIMPLE);
        Integer rq = Integer.parseInt(localDate.format( DateTimeFormatter.ofPattern("yyyyMMdd")));
        List<TXlBc> list = xlBcMapper.selectList(Wrappers.<TXlBc>lambdaQuery().eq(TXlBc::getRqint,rq));

        return list;
    }

    /**
     * 3、企业班次数据 t_QY_BC
     * @param searchDto
     * @return
     * @throws Exception
     */
    public List<TQyBc> selectTQyBcList(SearchDto searchDto) throws Exception{
        log.info("selectTQyBcList invoke...");

        LocalDate localDate = DateUtils.StrToLocalDate(searchDto.getSearchDate(),DateUtils.FORMAT_SIMPLE);
        Integer rq = Integer.parseInt(localDate.format( DateTimeFormatter.ofPattern("yyyyMMdd")));
        List<TQyBc> list = qyBcMapper.selectList(Wrappers.<TQyBc>lambdaQuery().eq(TQyBc::getRqint,rq));

        return list;
    }

    /**
     * 4、线路首末班发车准点数据 t_XL_shoumobanfczd
     * @param searchDto
     * @return
     * @throws Exception
     */
    public List<TXlShoumobanfczd> selectTXlShoumobanfczdList(SearchDto searchDto) throws Exception{
        log.info("selectTXlShoumobanfczdList invoke...");

        LocalDate localDate = DateUtils.StrToLocalDate(searchDto.getSearchDate(),DateUtils.FORMAT_SIMPLE);
        Integer rq = Integer.parseInt(localDate.format( DateTimeFormatter.ofPattern("yyyyMMdd")));
        List<TXlShoumobanfczd> list = xlShoumobanfczdMapper.selectList(Wrappers.<TXlShoumobanfczd>lambdaQuery().eq(TXlShoumobanfczd::getRqint,rq));

        return list;
    }

    /**
     * 5、企业首末班发车准点数据 t_QY_shoumobanfczd
     * @param searchDto
     * @return
     * @throws Exception
     */
    public List<TQyShoumobanfczd> selectTQyShoumobanfczdList(SearchDto searchDto) throws Exception{
        log.info("selectTQyShoumobanfczdList invoke...");

        LocalDate localDate = DateUtils.StrToLocalDate(searchDto.getSearchDate(),DateUtils.FORMAT_SIMPLE);
        Integer rq = Integer.parseInt(localDate.format( DateTimeFormatter.ofPattern("yyyyMMdd")));
        List<TQyShoumobanfczd> list = qyShoumobanfczdMapper.selectList(Wrappers.<TQyShoumobanfczd>lambdaQuery().eq(TQyShoumobanfczd::getRqint,rq));
        return list;
    }

    /**
     * 6、线路起讫站发车准点数据 t_XL_qiqizhanfczd
     * @param searchDto
     * @return
     * @throws Exception
     */
    public List<TXlQiqizhanfczd> selectTXlQiqizhanfczdList(SearchDto searchDto) throws Exception{
        log.info("selectTXlQiqizhanfczdList invoke...");
        LocalDate localDate = DateUtils.StrToLocalDate(searchDto.getSearchDate(),DateUtils.FORMAT_SIMPLE);
        Integer rq = Integer.parseInt(localDate.format( DateTimeFormatter.ofPattern("yyyyMMdd")));
        List<TXlQiqizhanfczd> list = xlQiqizhanfczdMapper.selectList(Wrappers.<TXlQiqizhanfczd>lambdaQuery().eq(TXlQiqizhanfczd::getRqint,rq));
        return list;
    }
    /**
     * 7、企业起讫站发车准点数据 t_QY_qiqizhanfczd
     * @param searchDto
     * @return
     * @throws Exception
     */
    public List<TQyQiqizhanfczd> selectTQyQiqizhanfczdList(SearchDto searchDto) throws Exception{
        log.info("selectTQyQiqizhanfczdList invoke...");
        LocalDate localDate = DateUtils.StrToLocalDate(searchDto.getSearchDate(),DateUtils.FORMAT_SIMPLE);
        Integer rq = Integer.parseInt(localDate.format( DateTimeFormatter.ofPattern("yyyyMMdd")));
        List<TQyQiqizhanfczd> list = qyQiqizhanfczdMapper.selectList(Wrappers.<TQyQiqizhanfczd>lambdaQuery().eq(TQyQiqizhanfczd::getRqint,rq));
        return list;
    }

    /**
     * 8、线路挂牌线路发车准点数据 t_XL_guapaifczd
     * @param searchDto
     * @return
     * @throws Exception
     */
    public List<TXlGuapaifczd> selectTXlGuapaifczdList(SearchDto searchDto) throws Exception{
        log.info("selectTXlGuapaifczdList invoke...");
        LocalDate localDate = DateUtils.StrToLocalDate(searchDto.getSearchDate(),DateUtils.FORMAT_SIMPLE);
        Integer rq = Integer.parseInt(localDate.format( DateTimeFormatter.ofPattern("yyyyMMdd")));
        List<TXlGuapaifczd> list = xlGuapaifczdMapper.selectList(Wrappers.<TXlGuapaifczd>lambdaQuery().eq(TXlGuapaifczd::getRqint,rq));
        return list;
    }

    /**
     * 9、企业挂牌线路发车准点数据 t_QY_guapaifczd
     * @param searchDto
     * @return
     * @throws Exception
     */
    public List<TQyGuapaifczd> selectTQyGuapaifczdList(SearchDto searchDto) throws Exception{
        log.info("selectTQyGuapaifczdList invoke...");
        LocalDate localDate = DateUtils.StrToLocalDate(searchDto.getSearchDate(),DateUtils.FORMAT_SIMPLE);
        Integer rq = Integer.parseInt(localDate.format( DateTimeFormatter.ofPattern("yyyyMMdd")));
        List<TQyGuapaifczd> list = qyGuapaifczdMapper.selectList(Wrappers.<TQyGuapaifczd>lambdaQuery().eq(TQyGuapaifczd::getRqint,rq));
        return list;

    }

    /**
     * 10、线路在线情况明细 t_XL_ZX
     * @param searchDto
     * @return
     * @throws Exception
     */
    public List<TXlZx> selectTXlZxList(SearchDto searchDto) throws Exception{
        log.info("selectTXlZxList invoke...");
        LocalDate localDate = DateUtils.StrToLocalDate(searchDto.getSearchDate(),DateUtils.FORMAT_SIMPLE);
        Integer rq = Integer.parseInt(localDate.format( DateTimeFormatter.ofPattern("yyyyMMdd")));
        List<TXlZx> list = xlZxMapper.selectList(Wrappers.<TXlZx>lambdaQuery().eq(TXlZx::getRqint,rq));
        return list;
    }

    /**
     * 11、企业线路在线情况统计 t_QY_ZX
     * @param searchDto
     * @return
     * @throws Exception
     */
    public List<TQyZx> selectTQyZxList(SearchDto searchDto) throws Exception{
        log.info("selectTQyZxList invoke...");
        LocalDate localDate = DateUtils.StrToLocalDate(searchDto.getSearchDate(),DateUtils.FORMAT_SIMPLE);
        Integer rq = Integer.parseInt(localDate.format( DateTimeFormatter.ofPattern("yyyyMMdd")));
        List<TQyZx> list = qyZxMapper.selectList(Wrappers.<TQyZx>lambdaQuery().eq(TQyZx::getRqint,rq));
        return list;

    }

    /**
     * 12、线路车辆在线情况数据 t_XL_CLZX
     * @param searchDto
     * @return
     * @throws Exception
     */
    public List<TXlClzx> selectTXlClzxList(SearchDto searchDto) throws Exception{
        log.info("selectTXlClzxList invoke...");
        LocalDate localDate = DateUtils.StrToLocalDate(searchDto.getSearchDate(),DateUtils.FORMAT_SIMPLE);
        Integer rq = Integer.parseInt(localDate.format( DateTimeFormatter.ofPattern("yyyyMMdd")));
        List<TXlClzx> list = xlClzxMapper.selectList(Wrappers.<TXlClzx>lambdaQuery().eq(TXlClzx::getRqint,rq));
        return list;

    }

    /**
     * 13、企业车辆在线情况数据 t_QY_CLZX
     * @param searchDto
     * @return
     * @throws Exception
     */
    public List<TQyClzx> selectTQyClzxList(SearchDto searchDto) throws Exception{
        log.info("selectTQyClzxList invoke...");
        LocalDate localDate = DateUtils.StrToLocalDate(searchDto.getSearchDate(),DateUtils.FORMAT_SIMPLE);
        Integer rq = Integer.parseInt(localDate.format( DateTimeFormatter.ofPattern("yyyyMMdd")));
        List<TQyClzx> list = qyClzxMapper.selectList(Wrappers.<TQyClzx>lambdaQuery().eq(TQyClzx::getRqint,rq));
        return list;
    }

    /**
     * 14、线路车辆出车情况数据 t_XL_CLCC
     * @param searchDto
     * @return
     * @throws Exception
     */
    public List<TXlClcc> selectTXlClccList(SearchDto searchDto) throws Exception{
        log.info("selectTXlClccList invoke...");
        LocalDate localDate = DateUtils.StrToLocalDate(searchDto.getSearchDate(),DateUtils.FORMAT_SIMPLE);
        Integer rq = Integer.parseInt(localDate.format( DateTimeFormatter.ofPattern("yyyyMMdd")));
        List<TXlClcc> list = xlClccMapper.selectList(Wrappers.<TXlClcc>lambdaQuery().eq(TXlClcc::getRqint,rq));
        return list;
    }

    /**
     * 15、企业车辆出车情况数据 t_QY_CLCC
     * @param searchDto
     * @return
     * @throws Exception
     */
    public List<TQyClcc> selectTQyClccList(SearchDto searchDto) throws Exception{
        log.info("selectTQyClccList invoke...");
        LocalDate localDate = DateUtils.StrToLocalDate(searchDto.getSearchDate(),DateUtils.FORMAT_SIMPLE);
        Integer rq = Integer.parseInt(localDate.format( DateTimeFormatter.ofPattern("yyyyMMdd")));
        List<TQyClcc> list = qyClccMapper.selectList(Wrappers.<TQyClcc>lambdaQuery().eq(TQyClcc::getRqint,rq));
        return list;
    }

    /**
     * -- 16、线路高峰时段班次配车执行情况 t_XL_GFBCPC
     * @param searchDto
     * @return
     * @throws Exception
     */
    public List<TXlGfbcpc> selectTXlGfbcpcList(SearchDto searchDto) throws Exception{
        log.info("selectTXlGfbcpcList invoke...");
        LocalDate localDate = DateUtils.StrToLocalDate(searchDto.getSearchDate(),DateUtils.FORMAT_SIMPLE);
        Integer rq = Integer.parseInt(localDate.format( DateTimeFormatter.ofPattern("yyyyMMdd")));
        List<TXlGfbcpc> list = xlGfbcpcMapper.selectList(Wrappers.<TXlGfbcpc>lambdaQuery().eq(TXlGfbcpc::getRqint,rq));
        return list;
    }

    /**
     * 17.创建线路平均行驶速度表 t_XL_pingjunCS
     * @param searchDto
     * @return
     * @throws Exception
     */
    public List<TXlPingjunCS> selectTXlPingjunCSList(SearchDto searchDto) throws Exception{
        log.info("selectTXlPingjunCSList invoke...");
        LocalDate localDate = DateUtils.StrToLocalDate(searchDto.getSearchDate(),DateUtils.FORMAT_SIMPLE);
        Integer rq = Integer.parseInt(localDate.format( DateTimeFormatter.ofPattern("yyyyMMdd")));
        List<TXlPingjunCS> list = xlPingjunCSMapper.selectList(Wrappers.<TXlPingjunCS>lambdaQuery().eq(TXlPingjunCS::getRqint,rq));
        return list;
    }
}
